# 输入日期，返回当天需要去的供应商，供应商的供货信息
# def Date_Get_message(str):
#
import csv
import Read_unit_infor
from data_wash import data_wash, get_loadunit_infor
from load_dwb import get_loadunit_infor_lwb
from read_loadunit import get_loadunit_infor1





    # print(res)
    # print(len(res))
# 完成装载单元数量的计算
all_arrays = process_loadData('2020-12-01')
# for i in range(0,len(all_arrays)):
#     print(all_arrays[i])
copy_all_arrays = []
for i in range(0, len(all_arrays)):
    temp = []
    for j in range(0, len(all_arrays[i])):
        temp.append(all_arrays[i][j])
    copy_all_arrays.append(temp)
# for i in range(0,len(all_arrays)):
#     print(copy_all_arrays[i])
# print(copy_all_arrays)
# print(copy_all_arrays)
# 将相同LOADUNIT加起来，输出格式是供应商代号，装载单元型号，装载单元总数量
def process_sameunit(process_arrays):
    # # 处理一行数据成另一行
    loadunit_num = get_loadunit_infor()
    print('\n')
    # print(process_arrays)
    # print(loadunit_num[0][34])
    res = []
    del(process_arrays[0])
    for i in range(0, len(process_arrays), 2):
        # print("i的值")
        # print(i)
        str = loadunit_num[1][loadunit_num[0].index(process_arrays[i])]
        # print(str)
        for j in range(i + 2, len(process_arrays), 2):
            # print("j的值")
            # print(j)
            # print(process_arrays[j])
            x = loadunit_num[0].index(process_arrays[j]) # 返回i后面的的供货商的
            # print(x)
            # print(loadunit_num[1][x])
            if(loadunit_num[1][x] == str):
                # print(x,j)
                # print(str)
                # print(loadunit_num[1][x])
                process_arrays[i + 1] += process_arrays[j + 1]
                process_arrays[j + 1] = 0
    # print(process_arrays)
    # 输出成功，现在用UNitload去替换
    True_res = []
    for i in range(0,len(process_arrays),2):
        if(process_arrays[i + 1] == 0):
            continue
        True_res.append(loadunit_num[1][loadunit_num[0].index(process_arrays[i])])
        True_res.append(process_arrays[i + 1])
    print(True_res)
    return True_res
for i in range(0,len(copy_all_arrays)):
    print(i)
    print(process_sameunit(copy_all_arrays[i]))

# 将数量多的装载单元，先挤一辆车出发
# 进行数据清洗，将供应商
# def arrange_Car(arrays):
#     # 按零件长度排序,长的排里边，判断能否排两个
#     LWH = get_loadunit_infor_lwb()
#     print(LWH[0])
#     # 全局坐标系,x,y
#     x = 0
#     y = 0
#     res = []
#     str_temp = arrays[0]
#     del(arrays[0])
#     for i in range(0, len(arrays), 2):
#         L = LWH[2][LWH[0].index(arrays[i])]
#         W = LWH[3][LWH[0].index(arrays[i])]
#         H = LWH[4][LWH[0].index(arrays[i])]
#         NUM = LWH[5][LWH[0].index(arrays[i])]
#         LOAD_UNIT = LWH[1][LWH.index(arrays[i])]
#         print(L,H,W,NUM)
#         if(int(L)<1200 and int(L)>800):
#             # 放两辆
#             if(int(H)<1200 and arrays[i + 1] > 1):
#                 # 高度上放两辆
#                 while arrays[i + 1] >3:
#                 s = '{}:{}:{}:{}:{}:{}:{}:{}'.format(str_temp,NUM,LOAD_UNIT,x,y,L,W,2)
#                 res.append(s)
#                 x = x + L
#                 s = '{}:{}:{}:{}:{}:{}:{}:{}'.format(str_temp,NUM,LOAD_UNIT,x + L,y,L,W,2)
#                 arrays[i + 1] = arrays[i + 1] - 2
#                 res.append(s)

# f = ['16789810', '6841184', 1.0, '6991425', 3.0, '6993381', 7.0, '9263409', 1.0, '9274404', 12.0, '9292534', 13.0, '9292547', 12.0, '9318584', 1.0, '9326770', 2.0, '9335227', 1.0, '9335229', 1.0, '9388422', 6.0, '9473787', 3.0]
# arrange_Car(f)
